package org.stvd.entities.admin;

import java.io.Serializable;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.format.annotation.DateTimeFormat;
import org.stvd.core.annotation.serializer.DateTimeSerializer;
import org.stvd.core.util.DateUtil;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;

/**
 * 系统平台ID-实体类
 * @author houzx
 */
@Entity
@Table(name = "guids")
public class Guids implements Serializable {

    private static final long serialVersionUID = -29468047078055646L;
    
    /**
     * 系统ID
     */
    @Id
    @Column(name="guid", nullable = false)
    private String guid = "";
    
    /**
     * 系统平台类型{-1：标识平台；1：业务平台；}
     */
    @Column(name="sys_module_type", nullable = false)
    @NotEmpty(message="平台类型不能为空")
    private String sysModuleType = "";
    
    /**
     * 系统平台编码
     */
    @Column(name="sys_module_code", nullable = false)
    @NotEmpty(message="平台编码不能为空")
    @Length(max = 10, message="平台编码超出最大长度限制")
    private String sysModuleCode = "";
    
    /**
     * 系统平台名称
     */
    @Column(name="sys_module_name", nullable = false)
    @NotEmpty(message="平台名称不能为空")
    @Length(max = 100, message="平台名称超出最大长度限制")
    private String sysModuleName = "";
    
    /**
     * 上级平台GUID
     */
    @Column(name="upper_guid", nullable = false)
    private String upperGuid = "";
    
    /**
     * 内部编码
     */
    @Column(name="inner_code", nullable = false)
    private String innerCode = "";
    
    /**
     * 系统版本
     */
    @Column(name="version_no", nullable = false)
    @NotEmpty(message="当前版本不能为空")
    private String versionNo = "";
    
    /**
     * 录入时间
     */
    @Column(name="indate", nullable = false)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = DateTimeSerializer.class)
    private Date indate = null;
    
    /**
     * 状态：T:启用，F:禁用
     */
    @Column(name="status", nullable = false)
    private String status = "";
    
    @Transient
    private String indateText = "";

    public String getGuid() {
        return guid;
    }

    public void setGuid(String guid) {
        this.guid = guid;
    }

    public String getSysModuleType() {
        return sysModuleType;
    }

    public void setSysModuleType(String sysModuleType) {
        this.sysModuleType = sysModuleType;
    }

    public String getSysModuleCode() {
        return sysModuleCode;
    }

    public void setSysModuleCode(String sysModuleCode) {
        this.sysModuleCode = sysModuleCode;
    }

    public String getSysModuleName() {
        return sysModuleName;
    }

    public void setSysModuleName(String sysModuleName) {
        this.sysModuleName = sysModuleName;
    }
    
    public String getUpperGuid() {
        return upperGuid;
    }

    public void setUpperGuid(String upperGuid) {
        this.upperGuid = upperGuid;
    }
    
    public String getInnerCode() {
        return innerCode;
    }

    public void setInnerCode(String innerCode) {
        this.innerCode = innerCode;
    }

    public String getVersionNo() {
        return versionNo;
    }

    public void setVersionNo(String versionNo) {
        this.versionNo = versionNo;
    }

    public Date getIndate() {
        return indate;
    }

    public void setIndate(Date indate) {
        this.indate = indate;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }
    
    public String getIndateText() {
        return indateText;
    }

    public void setIndateText(String indateText) {
        this.indateText=indateText;
        if(indateText != null && !indateText.equals("")){
            try{
                this.indate = DateUtil.YMD.parse(indateText);
            } catch(Exception ex){}
        }
    }

}
